package com.cuckoo.mall.thus.menuaccount.favorite;

import android.os.Bundle;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.bgn.baseframe.base.BaseActivity;
import com.bgn.baseframe.utils.UiUtil;
import com.cuckoo.mall.R;

/**
 * Created by Administrator on 2018/3/30.
 */

@Route(path = "/mall/favoriteActivity", group = "mall")
public class FavoriteActivity extends BaseActivity {
    private boolean isEdsitMode = false;
    private FavoriteFragment favoriteFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(createFragmentContainnerView());
        getTitleBar().setTitle(R.string.myfavorite).setRightText(getString(R.string.edit)).setRightTextColor(UiUtil.getColor(R.color.red)).setRightTextClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (favoriteFragment == null) {
                    return;
                }
                if (isEdsitMode) {
                    isEdsitMode = false;
                    getTitleBar().setRightText(getString(R.string.edit));
                } else {
                    isEdsitMode = true;
                    getTitleBar().setRightText(getString(R.string.complit));
                }
                favoriteFragment.setMode(isEdsitMode);
            }
        }).hideRightTextView();
        favoriteFragment = new FavoriteFragment();
        loadFragment(favoriteFragment, 0);
    }

    public void togleEditButton(boolean isShow) {
        if (isShow) {
            getTitleBar().showRightTextView();
        } else {
            getTitleBar().hideRightTextView();
        }

    }

}
